package com.xinggq.common.config;

import com.xinggq.common.interceptor.TraceInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web MVC配置类
 * 注册拦截器
 *
 * @since 2024
 */
@Configuration
public class CommonWebMvcConfig implements WebMvcConfigurer {
    
    @Autowired
    private TraceInterceptor traceInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册链路追踪拦截器，优先级最高
        registry.addInterceptor(traceInterceptor)
                .addPathPatterns("/**");
    }
}